﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using SVC.client;
namespace UI.Forms
{
    public partial class bank : FormBase1
    {
        //private SVC.client.shop cur = null;
        public bank()
        {
            InitializeComponent();
        }

        private void btn_new_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            add_bank frm = new add_bank();
            frm.FatherRefresh = bind;
            frm.Show();
        }

        private void btn_update_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (gridView1.FocusedRowHandle < 0) return;
            SVC.client.bank b = gridView1.GetRow(gridView1.FocusedRowHandle) as SVC.client.bank;
            if (b == null) return;

            bank_U frm = new bank_U(b);
            frm.FatherRefresh = bind;
            frm.ShowDialog();

        }

        private void btn_delete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (gridView1.FocusedRowHandle < 0) return;
            SVC.client.bank b = gridView1.GetRow(gridView1.FocusedRowHandle) as SVC.client.bank;
            if (b == null) return;
            
            string r = my.bw.bankBybankid_Delete(b.bankid, my.ACID);
            if (string.IsNullOrEmpty(r))
            {
                bind();
            }
            else
            {
                Comm.ShowErorr(r);
            }
        }

        private void shop_Load(object sender, EventArgs e)
        {
            bind();
        }

        private void bind()
        {
            gridControl1.DataSource = my.bw.bank_Get("", my.ACID);
        }

 

        private void btn_sx_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {

            bind();
        }
    }
}